home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / PInterfaces / SCSI.p < prev    next >
Text File  |  1996-05-01  |  58KB  |  1,256 lines

  1. {
  2.      File:        SCSI.p
  3.  
  4.      Contains:    SCSI Family Interfaces.
  5.  
  6.      Version:    Technology:    System 8.0
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT SCSI;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __SCSI__}
  28. {$SETC __SCSI__ := 1}
  29.  
  30. {$I+}
  31. {$SETC SCSIIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __MIXEDMODE__}
  38. {$I MixedMode.p}
  39. {$ENDC}
  40. {$IFC FOR_SYSTEM8_PREEMPTIVE }
  41. {$IFC UNDEFINED __KERNEL__}
  42. {$I Kernel.p}
  43. {$ENDC}
  44. {$IFC UNDEFINED __NAMEREGISTRY__}
  45. {$I NameRegistry.p}
  46. {$ENDC}
  47. {$IFC UNDEFINED __IOITERATOR__}
  48. {$I IOIterator.p}
  49. {$ENDC}
  50. {$ENDC}
  51.  
  52. {$PUSH}
  53. {$ALIGN MAC68K}
  54. {$LibExport+}
  55.  
  56. {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE }
  57. {  SCSI Manager errors  }
  58.  
  59. CONST
  60.     scCommErr                    = 2;                            {  communications error, operation timeout  }
  61.     scArbNBErr                    = 3;                            {  arbitration timeout waiting for not BSY  }
  62.     scBadParmsErr                = 4;                            {  bad parameter or TIB opcode  }
  63.     scPhaseErr                    = 5;                            {  SCSI bus not in correct phase for attempted operation  }
  64.     scCompareErr                = 6;                            {  data compare error  }
  65.     scMgrBusyErr                = 7;                            {  SCSI Manager busy   }
  66.     scSequenceErr                = 8;                            {  attempted operation is out of sequence  }
  67.     scBusTOErr                    = 9;                            {  CPU bus timeout  }
  68.     scComplPhaseErr                = 10;                            {  SCSI bus wasn't in Status phase  }
  69.  
  70. {$ENDC}
  71. {$IFC FOR_SYSTEM7_ONLY }
  72. {  TIB opcodes  }
  73.  
  74. CONST
  75.     scInc                        = 1;
  76.     scNoInc                        = 2;
  77.     scAdd                        = 3;
  78.     scMove                        = 4;
  79.     scLoop                        = 5;
  80.     scNop                        = 6;
  81.     scStop                        = 7;
  82.     scComp                        = 8;
  83.  
  84. {  Signatures  }
  85.     sbSIGWord                    = $4552;                        {  signature word for Block 0 ('ER')  }
  86.     sbMac                        = 1;                            {  system type for Mac  }
  87.     pMapSIG                        = $504D;                        {  partition map signature ('PM')  }
  88.     pdSigWord                    = $5453;
  89.  
  90.     oldPMSigWord                = $5453;
  91.     newPMSigWord                = $504D;
  92.  
  93. {  Driver Descriptor Map  }
  94.  
  95. TYPE
  96.     Block0Ptr = ^Block0;
  97.     Block0 = PACKED RECORD
  98.         sbSig:                    INTEGER;                                {  unique value for SCSI block 0  }
  99.         sbBlkSize:                INTEGER;                                {  block size of device  }
  100.         sbBlkCount:                LONGINT;                                {  number of blocks on device  }
  101.         sbDevType:                INTEGER;                                {  device type  }
  102.         sbDevId:                INTEGER;                                {  device id  }
  103.         sbData:                    LONGINT;                                {  not used  }
  104.         sbDrvrCount:            INTEGER;                                {  driver descriptor count  }
  105.         ddBlock:                LONGINT;                                {  1st driver's starting block  }
  106.         ddSize:                    INTEGER;                                {  size of 1st driver (512-byte blks)  }
  107.         ddType:                    INTEGER;                                {  system type (1 for Mac+)  }
  108.         ddPad:                    ARRAY [0..242] OF INTEGER;                {  ARRAY[0..242] OF INTEGER; not used  }
  109.     END;
  110.  
  111. { Driver descriptor }
  112.     DDMapPtr = ^DDMap;
  113.     DDMap = RECORD
  114.         ddBlock:                LONGINT;                                {  1st driver's starting block  }
  115.         ddSize:                    INTEGER;                                {  size of 1st driver (512-byte blks)  }
  116.         ddType:                    INTEGER;                                {  system type (1 for Mac+)  }
  117.     END;
  118.  
  119. {  Partition Map Entry  }
  120.     PartitionPtr = ^Partition;
  121.     Partition = PACKED RECORD
  122.         pmSig:                    INTEGER;                                {  unique value for map entry blk  }
  123.         pmSigPad:                INTEGER;                                {  currently unused  }
  124.         pmMapBlkCnt:            LONGINT;                                {  # of blks in partition map  }
  125.         pmPyPartStart:            LONGINT;                                {  physical start blk of partition  }
  126.         pmPartBlkCnt:            LONGINT;                                {  # of blks in this partition  }
  127.         pmPartName:                PACKED ARRAY [0..31] OF UInt8;            {  ASCII partition name  }
  128.         pmParType:                PACKED ARRAY [0..31] OF UInt8;            {  ASCII partition type  }
  129.         pmLgDataStart:            LONGINT;                                {  log. # of partition's 1st data blk  }
  130.         pmDataCnt:                LONGINT;                                {  # of blks in partition's data area  }
  131.         pmPartStatus:            LONGINT;                                {  bit field for partition status  }
  132.         pmLgBootStart:            LONGINT;                                {  log. blk of partition's boot code  }
  133.         pmBootSize:                LONGINT;                                {  number of bytes in boot code  }
  134.         pmBootAddr:                LONGINT;                                {  memory load address of boot code  }
  135.         pmBootAddr2:            LONGINT;                                {  currently unused  }
  136.         pmBootEntry:            LONGINT;                                {  entry point of boot code  }
  137.         pmBootEntry2:            LONGINT;                                {  currently unused  }
  138.         pmBootCksum:            LONGINT;                                {  checksum of boot code  }
  139.         pmProcessor:            PACKED ARRAY [0..15] OF UInt8;            {  ASCII for the processor type  }
  140.         pmPad:                    ARRAY [0..187] OF INTEGER;                {  ARRAY[0..187] OF INTEGER; not used  }
  141.     END;
  142.  
  143. {  TIB instruction  }
  144.     SCSIInstrPtr = ^SCSIInstr;
  145.     SCSIInstr = RECORD
  146.         scOpcode:                INTEGER;
  147.         scParam1:                LONGINT;
  148.         scParam2:                LONGINT;
  149.     END;
  150.  
  151. {  SCSI Phases (used by SIMs to support the Original SCSI Manager  }
  152.  
  153. CONST
  154.     kDataOutPhase                = 0;                            {  Encoded MSG, C/D, I/O bits  }
  155.     kDataInPhase                = 1;
  156.     kCommandPhase                = 2;
  157.     kStatusPhase                = 3;
  158.     kPhaseIllegal0                = 4;
  159.     kPhaseIllegal1                = 5;
  160.     kMessageOutPhase            = 6;
  161.     kMessageInPhase                = 7;
  162.     kBusFreePhase                = 8;                            {  Additional Phases  }
  163.     kArbitratePhase                = 9;
  164.     kSelectPhase                = 10;
  165.     kMessageInPhaseNACK            = 11;                            {  Message In Phase with ACK hanging on the bus  }
  166.  
  167. FUNCTION SCSIReset: OSErr;
  168.     {$IFC NOT GENERATINGCFM}
  169.     INLINE $4267, $A815;
  170.     {$ENDC}
  171. FUNCTION SCSIGet: OSErr;
  172.     {$IFC NOT GENERATINGCFM}
  173.     INLINE $3F3C, $0001, $A815;
  174.     {$ENDC}
  175. FUNCTION SCSISelect(targetID: INTEGER): OSErr;
  176.     {$IFC NOT GENERATINGCFM}
  177.     INLINE $3F3C, $0002, $A815;
  178.     {$ENDC}
  179. FUNCTION SCSICmd(buffer: Ptr; count: INTEGER): OSErr;
  180.     {$IFC NOT GENERATINGCFM}
  181.     INLINE $3F3C, $0003, $A815;
  182.     {$ENDC}
  183. FUNCTION SCSIRead(tibPtr: Ptr): OSErr;
  184.     {$IFC NOT GENERATINGCFM}
  185.     INLINE $3F3C, $0005, $A815;
  186.     {$ENDC}
  187. FUNCTION SCSIRBlind(tibPtr: Ptr): OSErr;
  188.     {$IFC NOT GENERATINGCFM}
  189.     INLINE $3F3C, $0008, $A815;
  190.     {$ENDC}
  191. FUNCTION SCSIWrite(tibPtr: Ptr): OSErr;
  192.     {$IFC NOT GENERATINGCFM}
  193.     INLINE $3F3C, $0006, $A815;
  194.     {$ENDC}
  195. FUNCTION SCSIWBlind(tibPtr: Ptr): OSErr;
  196.     {$IFC NOT GENERATINGCFM}
  197.     INLINE $3F3C, $0009, $A815;
  198.     {$ENDC}
  199. FUNCTION SCSIComplete(VAR stat: INTEGER; VAR message: INTEGER; wait: LONGINT): OSErr;
  200.     {$IFC NOT GENERATINGCFM}
  201.     INLINE $3F3C, $0004, $A815;
  202.     {$ENDC}
  203. FUNCTION SCSIStat: INTEGER;
  204.     {$IFC NOT GENERATINGCFM}
  205.     INLINE $3F3C, $000A, $A815;
  206.     {$ENDC}
  207. FUNCTION SCSISelAtn(targetID: INTEGER): OSErr;
  208.     {$IFC NOT GENERATINGCFM}
  209.     INLINE $3F3C, $000B, $A815;
  210.     {$ENDC}
  211. FUNCTION SCSIMsgIn(VAR message: INTEGER): OSErr;
  212.     {$IFC NOT GENERATINGCFM}
  213.     INLINE $3F3C, $000C, $A815;
  214.     {$ENDC}
  215. FUNCTION SCSIMsgOut(message: INTEGER): OSErr;
  216.     {$IFC NOT GENERATINGCFM}
  217.     INLINE $3F3C, $000D, $A815;
  218.     {$ENDC}
  219.  
  220. CONST
  221.     scsiVERSION                    = 43;
  222.  
  223. {$ENDC}
  224. {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE }
  225. {  SCSI Callback Procedure Prototypes  }
  226.  
  227. TYPE
  228.     AENCallbackProcPtr = ProcPtr;  { PROCEDURE AENCallback; C; }
  229.  
  230.     SIMInitProcPtr = ProcPtr;  { FUNCTION SIMInit(SIMinfoPtr: Ptr): OSErr; C; }
  231.  
  232.     SIMActionProcPtr = ProcPtr;  { PROCEDURE SIMAction(scsiPB: UNIV Ptr; SIMGlobals: Ptr); C; }
  233.  
  234.     SCSIProcPtr = ProcPtr;  { PROCEDURE SCSI; C; }
  235.  
  236.     SCSIMakeCallbackProcPtr = ProcPtr;  { PROCEDURE SCSIMakeCallback(scsiPB: UNIV Ptr); C; }
  237.  
  238. {  SCSIInterruptPollProcPtr is obsolete (use SCSIInterruptProcPtr) but still here for compatibility  }
  239.     SCSIInterruptPollProcPtr = ProcPtr;  { FUNCTION SCSIInterruptPoll(SIMGlobals: Ptr): LONGINT; C; }
  240.  
  241.     SCSIInterruptProcPtr = ProcPtr;  { FUNCTION SCSIInterrupt(SIMGlobals: Ptr): LONGINT; C; }
  242.  
  243.     AENCallbackUPP = UniversalProcPtr;
  244.     SIMInitUPP = UniversalProcPtr;
  245.     SIMActionUPP = UniversalProcPtr;
  246.     SCSIUPP = UniversalProcPtr;
  247.     SCSIMakeCallbackUPP = UniversalProcPtr;
  248.     SCSIInterruptPollUPP = UniversalProcPtr;
  249.     SCSIInterruptUPP = UniversalProcPtr;
  250. {$ENDC}
  251. {$IFC FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE }
  252.  
  253. TYPE
  254.     SCSICallbackProcPtr = ProcPtr;  { PROCEDURE SCSICallback(scsiPB: UNIV Ptr); }
  255.  
  256.     SCSICallbackUPP = UniversalProcPtr;
  257. {$ENDC}
  258. {$IFC FOR_SYSTEM7_ONLY }
  259.  
  260. CONST
  261.     uppAENCallbackProcInfo = $00000001;
  262.     uppSIMInitProcInfo = $000000E1;
  263.     uppSIMActionProcInfo = $000003C1;
  264.     uppSCSIProcInfo = $00000001;
  265.     uppSCSIMakeCallbackProcInfo = $000000C1;
  266.     uppSCSIInterruptPollProcInfo = $000000F1;
  267.     uppSCSIInterruptProcInfo = $000000F1;
  268.     uppSCSICallbackProcInfo = $000000C0;
  269.  
  270. FUNCTION NewAENCallbackProc(userRoutine: AENCallbackProcPtr): AENCallbackUPP;
  271.     {$IFC NOT GENERATINGCFM }
  272.     INLINE $2E9F;
  273.     {$ENDC}
  274.  
  275. FUNCTION NewSIMInitProc(userRoutine: SIMInitProcPtr): SIMInitUPP;
  276.     {$IFC NOT GENERATINGCFM }
  277.     INLINE $2E9F;
  278.     {$ENDC}
  279.  
  280. FUNCTION NewSIMActionProc(userRoutine: SIMActionProcPtr): SIMActionUPP;
  281.     {$IFC NOT GENERATINGCFM }
  282.     INLINE $2E9F;
  283.     {$ENDC}
  284.  
  285. FUNCTION NewSCSIProc(userRoutine: SCSIProcPtr): SCSIUPP;
  286.     {$IFC NOT GENERATINGCFM }
  287.     INLINE $2E9F;
  288.     {$ENDC}
  289.  
  290. FUNCTION NewSCSIMakeCallbackProc(userRoutine: SCSIMakeCallbackProcPtr): SCSIMakeCallbackUPP;
  291.     {$IFC NOT GENERATINGCFM }
  292.     INLINE $2E9F;
  293.     {$ENDC}
  294.  
  295. FUNCTION NewSCSIInterruptPollProc(userRoutine: SCSIInterruptPollProcPtr): SCSIInterruptPollUPP;
  296.     {$IFC NOT GENERATINGCFM }
  297.     INLINE $2E9F;
  298.     {$ENDC}
  299.  
  300. FUNCTION NewSCSIInterruptProc(userRoutine: SCSIInterruptProcPtr): SCSIInterruptUPP;
  301.     {$IFC NOT GENERATINGCFM }
  302.     INLINE $2E9F;
  303.     {$ENDC}
  304.  
  305. FUNCTION NewSCSICallbackProc(userRoutine: SCSICallbackProcPtr): SCSICallbackUPP;
  306.     {$IFC NOT GENERATINGCFM }
  307.     INLINE $2E9F;
  308.     {$ENDC}
  309.  
  310. PROCEDURE CallAENCallbackProc(userRoutine: AENCallbackUPP);
  311.     {$IFC NOT GENERATINGCFM}
  312.     {To be implemented:  Glue to move parameters into registers.}
  313.     {$ENDC}
  314.  
  315. FUNCTION CallSIMInitProc(SIMinfoPtr: Ptr; userRoutine: SIMInitUPP): OSErr;
  316.     {$IFC NOT GENERATINGCFM}
  317.     {To be implemented:  Glue to move parameters into registers.}
  318.     {$ENDC}
  319.  
  320. PROCEDURE CallSIMActionProc(scsiPB: UNIV Ptr; SIMGlobals: Ptr; userRoutine: SIMActionUPP);
  321.     {$IFC NOT GENERATINGCFM}
  322.     {To be implemented:  Glue to move parameters into registers.}
  323.     {$ENDC}
  324.  
  325. PROCEDURE CallSCSIProc(userRoutine: SCSIUPP);
  326.     {$IFC NOT GENERATINGCFM}
  327.     {To be implemented:  Glue to move parameters into registers.}
  328.     {$ENDC}
  329.  
  330. PROCEDURE CallSCSIMakeCallbackProc(scsiPB: UNIV Ptr; userRoutine: SCSIMakeCallbackUPP);
  331.     {$IFC NOT GENERATINGCFM}
  332.     {To be implemented:  Glue to move parameters into registers.}
  333.     {$ENDC}
  334.  
  335. FUNCTION CallSCSIInterruptPollProc(SIMGlobals: Ptr; userRoutine: SCSIInterruptPollUPP): LONGINT;
  336.     {$IFC NOT GENERATINGCFM}
  337.     {To be implemented:  Glue to move parameters into registers.}
  338.     {$ENDC}
  339.  
  340. FUNCTION CallSCSIInterruptProc(SIMGlobals: Ptr; userRoutine: SCSIInterruptUPP): LONGINT;
  341.     {$IFC NOT GENERATINGCFM}
  342.     {To be implemented:  Glue to move parameters into registers.}
  343.     {$ENDC}
  344.  
  345. PROCEDURE CallSCSICallbackProc(scsiPB: UNIV Ptr; userRoutine: SCSICallbackUPP);
  346.     {$IFC NOT GENERATINGCFM}
  347.     INLINE $205F, $4E90;
  348.     {$ENDC}
  349. {$ENDC}
  350. {$IFC FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE }
  351. {  SCSI Manager function codes  }
  352.  
  353. CONST
  354.     SCSINop                        = $00;                            {  Execute nothing                                          }
  355.     SCSIExecIO                    = $01;                            {  Execute the specified IO                              }
  356.     SCSIBusInquiry                = $03;                            {  Get parameters for entire path of HBAs                  }
  357.     SCSIReleaseQ                = $04;                            {  Release the frozen SIM queue for particular LUN          }
  358.     SCSIAbortCommand            = $10;                            {  Abort the selected Control Block                       }
  359.     SCSIResetBus                = $11;                            {  Reset the SCSI bus                                       }
  360.     SCSIResetDevice                = $12;                            {  Reset the SCSI device                                   }
  361.     SCSITerminateIO                = $13;                            {  Terminate any pending IO                               }
  362.     SCSIGetVirtualIDInfo        = $80;                            {  Find out which bus old ID is on                          }
  363.     SCSILoadDriver                = $82;                            {  Load a driver for a device ident                      }
  364.     SCSIOldCall                    = $84;                            {  XPT->SIM private call for old-API                      }
  365.     SCSICreateRefNumXref        = $85;                            {  Register a DeviceIdent to drvr RefNum xref              }
  366.     SCSILookupRefNumXref        = $86;                            {  Get DeviceIdent to drvr RefNum xref                      }
  367.     SCSIRemoveRefNumXref        = $87;                            {  Remove a DeviceIdent to drvr RefNum xref              }
  368.     SCSIRegisterWithNewXPT        = $88;                            {  XPT has changed - SIM needs to re-register itself      }
  369.     vendorUnique                = $C0;                            {  0xC0 thru 0xFF  }
  370.  
  371. {  Define DeviceIdent structure  }
  372.  
  373. TYPE
  374.     DeviceIdentPtr = ^DeviceIdent;
  375.     DeviceIdent = PACKED RECORD
  376.         diReserved:                UInt8;                                    {  reserved                  }
  377.         bus:                    UInt8;                                    {  SCSI - Bus Number         }
  378.         targetID:                UInt8;                                    {  SCSI - Target SCSI ID     }
  379.         LUN:                    UInt8;                                    {  SCSI - LUN                   }
  380.     END;
  381.  
  382. {
  383.  #endif // FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  384.  #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  385. }
  386. {  Allocation length defines for some of the fields  }
  387.  
  388. CONST
  389.     handshakeDataLength            = 8;                            {  Handshake data length  }
  390.     maxCDBLength                = 16;                            {  Space for the CDB bytes/pointer  }
  391.     vendorIDLength                = 16;                            {  ASCII string len for Vendor ID   }
  392.  
  393.  
  394. TYPE
  395.     SCSIDataPtr                            = ^UInt8;
  396. {  Command Descriptor Block structure  }
  397.     CDBPtr = ^CDB;
  398.     CDB = RECORD
  399.         CASE INTEGER OF
  400.         0: (
  401.             cdbPtr:                BytePtr;                                {  pointer to the CDB, or  }
  402.             );
  403.         1: (
  404.             cdbBytes:            PACKED ARRAY [0..15] OF UInt8;            {  the actual CDB to send  }
  405.             );
  406.     END;
  407.  
  408. {  Scatter/gather list element  }
  409.     SGRecordPtr = ^SGRecord;
  410.     SGRecord = RECORD
  411.         SGAddr:                    Ptr;
  412.         SGCount:                UInt32;
  413.     END;
  414.  
  415. {
  416.  #endif    // FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  417.  #if FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  418. }
  419.     SCSIHdrPtr = ^SCSIHdr;
  420.     SCSIHdr = RECORD
  421.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  422.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  423.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  424.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  425.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  426.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  427.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  428.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  429.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  430.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  431.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  432.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  433.     END;
  434.  
  435.     SCSI_PBPtr = ^SCSI_PB;
  436.     SCSI_PB = RECORD
  437.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  438.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  439.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  440.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  441.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  442.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  443.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  444.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  445.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  446.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  447.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  448.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  449.     END;
  450.  
  451. {
  452.  #endif    // FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE
  453.   This is temporary until we have connection protocol ready.
  454.  #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  455. }
  456.     SCSI_IOPtr = ^SCSI_IO;
  457.     SCSI_IO = RECORD
  458.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  459.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  460.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  461.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  462.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  463.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  464.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  465.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  466.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  467.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  468.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  469.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  470.         scsiResultFlags:        UInt16;                                    {  <- Flags which modify the scsiResult field         }
  471.         scsiReserved3pt5:        UInt16;                                    {  -> Reserved                                         }
  472.         scsiDataPtr:            BytePtr;                                {  -> Pointer to the data buffer or the S/G list       }
  473.         scsiDataLength:            UInt32;                                    {  -> Data transfer length                             }
  474.         scsiSensePtr:            BytePtr;                                {  -> Ptr to autosense data buffer                   }
  475.         scsiSenseLength:        SInt8;                                    {  -> size of the autosense buffer                      }
  476.         scsiCDBLength:            SInt8;                                    {  -> Number of bytes for the CDB                       }
  477.         scsiSGListCount:        UInt16;                                    {  -> num of scatter gather list entries               }
  478.         scsiReserved4:            UInt32;                                    {  <-     reserved for output                             }
  479.         scsiSCSIstatus:            SInt8;                                    {  <- Returned scsi device status                       }
  480.         scsiSenseResidual:        SInt8;                                    {  <- Autosense residual length                       }
  481.         scsiReserved5:            UInt16;                                    {  <-     reserved for output                              }
  482.         scsiDataResidual:        LONGINT;                                {  <- Returned Transfer residual length               }
  483.         scsiCDB:                CDB;                                    {  -> Actual CDB or pointer to CDB                   }
  484.         scsiTimeout:            LONGINT;                                {  -> Timeout value (Time Mgr format) (CAM timeout)  }
  485.         scsiReserved5pt5:        BytePtr;                                {  -> Reserved                                         }
  486.         scsiReserved5pt6:        UInt16;                                    {  -> Reserved                                         }
  487.         scsiIOFlags:            UInt16;                                    {  -> additional I/O flags                                }
  488.         scsiTagAction:            SInt8;                                    {  -> What to do for tag queuing                        }
  489.         scsiReserved6:            SInt8;                                    {  ->     reserved for input                              }
  490.         scsiReserved7:            UInt16;                                    {  ->     reserved for input                              }
  491.         scsiSelectTimeout:        UInt16;                                    {  -> Select timeout value                              }
  492.         scsiDataType:            SInt8;                                    {  -> Data description type (i.e. buffer, TIB, S/G)     }
  493.         scsiTransferType:        SInt8;                                    {  -> Transfer type (i.e. Blind vs Polled)              }
  494.         scsiReserved8:            UInt32;                                    {  ->     reserved for input                              }
  495.         scsiReserved9:            UInt32;                                    {  ->     reserved for input                              }
  496.         scsiHandshake:            ARRAY [0..7] OF UInt16;                    {  -> handshaking points (null term'd)     }
  497.         scsiReserved10:            UInt32;                                    {  ->     reserved for input                              }
  498.         scsiReserved11:            UInt32;                                    {  ->   reserved for input                             }
  499.         scsiCommandLink:        SCSI_IOPtr;                                {  -> Ptr to the next PB in linked cmd chain          }
  500.         scsiSIMpublics:            PACKED ARRAY [0..7] OF UInt8;            {  ->     reserved for input to 3rd-party SIMs         }
  501.         scsiAppleReserved6:        PACKED ARRAY [0..7] OF UInt8;            {  ->    reserved for input                               }
  502.                                                                         {  XPT layer privates (for old-API emulation)  }
  503.         scsiCurrentPhase:        UInt16;                                    {  <- phase upon completing old call                   }
  504.         scsiSelector:            INTEGER;                                {  -> selector specified in old calls                   }
  505.         scsiOldCallResult:        OSErr;                                    {  <- result of old call                               }
  506.         scsiSCSImessage:        SInt8;                                    {  <- Returned scsi device message (for SCSIComplete) }
  507.         XPTprivateFlags:        SInt8;                                    {  <> various flags                                    }
  508.         XPTextras:                PACKED ARRAY [0..11] OF UInt8;            {                                                      }
  509.     END;
  510.  
  511.     SCSIExecIOPB                        = SCSI_IO;
  512.     SCSIExecIOPBPtr                     = ^SCSIExecIOPB;
  513. {  Bus inquiry PB  }
  514.     SCSIBusInquiryPBPtr = ^SCSIBusInquiryPB;
  515.     SCSIBusInquiryPB = RECORD
  516.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  517.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  518.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  519.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  520.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  521.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  522.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  523.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  524.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  525.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  526.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  527.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  528.         scsiEngineCount:        UInt16;                                    {  <- Number of engines on HBA                          }
  529.         scsiMaxTransferType:    UInt16;                                    {  <- Number of transfer types for this HBA             }
  530.         scsiDataTypes:            UInt32;                                    {  <- which data types are supported by this SIM      }
  531.         scsiIOpbSize:            UInt16;                                    {  <- Size of SCSI_IO PB for this SIM/HBA              }
  532.         scsiMaxIOpbSize:        UInt16;                                    {  <- Size of max SCSI_IO PB for all SIM/HBAs          }
  533.         scsiFeatureFlags:        UInt32;                                    {  <- Supported features flags field                  }
  534.         scsiVersionNumber:        SInt8;                                    {  <- Version number for the SIM/HBA                  }
  535.         scsiHBAInquiry:            SInt8;                                    {  <- Mimic of INQ byte 7 for the HBA                  }
  536.         scsiTargetModeFlags:    SInt8;                                    {  <- Flags for target mode support                  }
  537.         scsiScanFlags:            SInt8;                                    {  <- Scan related feature flags                      }
  538.         scsiSIMPrivatesPtr:        UInt32;                                    {  <- Ptr to SIM private data area                      }
  539.         scsiSIMPrivatesSize:    UInt32;                                    {  <- Size of SIM private data area                  }
  540.         scsiAsyncFlags:            UInt32;                                    {  <- Event cap. for Async Callback                  }
  541.         scsiHiBusID:            SInt8;                                    {  <- Highest path ID in the subsystem               }
  542.         scsiInitiatorID:        SInt8;                                    {  <- ID of the HBA on the SCSI bus                  }
  543.         scsiBIReserved0:        UInt16;                                    {                                                      }
  544.         scsiBIReserved1:        UInt32;                                    {  <-                                                   }
  545.         scsiFlagsSupported:        UInt32;                                    {  <- which scsiFlags are supported                  }
  546.         scsiIOFlagsSupported:    UInt16;                                    {  <- which scsiIOFlags are supported                  }
  547.         scsiWeirdStuff:            UInt16;                                    {  <-                                                  }
  548.         scsiMaxTarget:            UInt16;                                    {  <- maximum Target number supported                  }
  549.         scsiMaxLUN:                UInt16;                                    {  <- maximum Logical Unit number supported          }
  550.         scsiSIMVendor:            PACKED ARRAY [0..15] OF CHAR;            {  <- Vendor ID of SIM (or XPT if bus<FF)          }
  551.         scsiHBAVendor:            PACKED ARRAY [0..15] OF CHAR;            {  <- Vendor ID of the HBA                          }
  552.         scsiControllerFamily:    PACKED ARRAY [0..15] OF CHAR;            {  <- Family of SCSI Controller                  }
  553.         scsiControllerType:        PACKED ARRAY [0..15] OF CHAR;            {  <- Specific Model of SCSI Controller used      }
  554.         scsiXPTversion:            PACKED ARRAY [0..3] OF CHAR;            {  <- version number of XPT                          }
  555.         scsiSIMversion:            PACKED ARRAY [0..3] OF CHAR;            {  <- version number of SIM                          }
  556.         scsiHBAversion:            PACKED ARRAY [0..3] OF CHAR;            {  <- version number of HBA                          }
  557.         scsiHBAslotType:        SInt8;                                    {  <- type of "slot" that this HBA is in             }
  558.         scsiHBAslotNumber:        SInt8;                                    {  <- slot number of this HBA                          }
  559.         scsiSIMsRsrcID:            UInt16;                                    {  <- resource ID of this SIM                          }
  560.         scsiBIReserved3:        UInt16;                                    {  <-                                                  }
  561.         scsiAdditionalLength:    UInt16;                                    {  <- additional BusInquiry PB len                     }
  562.     END;
  563.  
  564. {  Abort SIM Request PB  }
  565.     SCSIAbortCommandPBPtr = ^SCSIAbortCommandPB;
  566.     SCSIAbortCommandPB = RECORD
  567.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  568.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  569.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  570.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  571.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  572.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  573.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  574.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  575.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  576.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  577.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  578.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  579.         scsiIOptr:                SCSI_IOPtr;                                {  Pointer to the PB to abort             }
  580.     END;
  581.  
  582. {  Terminate I/O Process Request PB  }
  583.     SCSITerminateIOPBPtr = ^SCSITerminateIOPB;
  584.     SCSITerminateIOPB = RECORD
  585.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  586.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  587.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  588.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  589.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  590.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  591.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  592.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  593.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  594.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  595.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  596.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  597.         scsiIOptr:                SCSI_IOPtr;                                {  Pointer to the PB to terminate          }
  598.     END;
  599.  
  600. {  Reset SCSI Bus PB  }
  601.     SCSIResetBusPBPtr = ^SCSIResetBusPB;
  602.     SCSIResetBusPB = RECORD
  603.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  604.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  605.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  606.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  607.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  608.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  609.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  610.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  611.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  612.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  613.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  614.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  615.     END;
  616.  
  617. {  Reset SCSI Device PB  }
  618.     SCSIResetDevicePBPtr = ^SCSIResetDevicePB;
  619.     SCSIResetDevicePB = RECORD
  620.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  621.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  622.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  623.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  624.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  625.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  626.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  627.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  628.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  629.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  630.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  631.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  632.     END;
  633.  
  634. {  Release SIM Queue PB  }
  635.     SCSIReleaseQPBPtr = ^SCSIReleaseQPB;
  636.     SCSIReleaseQPB = RECORD
  637.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  638.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  639.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  640.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  641.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  642.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  643.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  644.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  645.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  646.         scsiDriverStorage:        BytePtr;                                {  <> Ptr for driver private use         }
  647.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  648.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  649.     END;
  650.  
  651. {$ENDC}
  652. {$IFC FOR_SYSTEM7_ONLY }
  653. {  SCSI Get Virtual ID Info PB  }
  654.  
  655. TYPE
  656.     SCSIGetVirtualIDInfoPBPtr = ^SCSIGetVirtualIDInfoPB;
  657.     SCSIGetVirtualIDInfoPB = RECORD
  658.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  659.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  660.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  661.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  662.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  663.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  664.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  665.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  666.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  667.         scsiDriverStorage:        Ptr;                                    {  <> Ptr for driver private use         }
  668.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  669.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  670.         scsiOldCallID:            UInt16;                                    {  -> SCSI ID of device in question      }
  671.         scsiExists:                BOOLEAN;                                {  <- true if device exists              }
  672.         filler:                    SInt8;
  673.     END;
  674.  
  675. {  Create/Lookup/Remove RefNum for Device PB  }
  676.     SCSIDriverPBPtr = ^SCSIDriverPB;
  677.     SCSIDriverPB = RECORD
  678.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  679.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  680.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  681.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  682.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  683.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  684.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  685.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  686.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  687.         scsiDriverStorage:        Ptr;                                    {  <> Ptr for driver private use         }
  688.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  689.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  690.         scsiDriver:                INTEGER;                                {  -> DriverRefNum, For SetDriver, <- For GetNextDriver  }
  691.         scsiDriverFlags:        UInt16;                                    {  <> Details of driver/device              }
  692.         scsiNextDevice:            DeviceIdent;                            {  <- DeviceIdent of the NEXT Item in the list   }
  693.     END;
  694.  
  695. {  Load Driver PB  }
  696.     SCSILoadDriverPBPtr = ^SCSILoadDriverPB;
  697.     SCSILoadDriverPB = RECORD
  698.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  699.         scsiReserved1:            INTEGER;                                {  ->     reserved for input                 }
  700.         scsiPBLength:            UInt16;                                    {  -> Length of the entire PB             }
  701.         scsiFunctionCode:        SInt8;                                    {  -> function selector                  }
  702.         scsiReserved2:            SInt8;                                    {  <-     reserved for output                 }
  703.         scsiResult:                OSErr;                                    {  <- Returned result                      }
  704.         scsiDevice:                DeviceIdent;                            {  -> Device Identifier (bus+target+lun) }
  705.         scsiCompletion:            SCSICallbackUPP;                        {  -> Callback on completion function       }
  706.         scsiFlags:                UInt32;                                    {  -> assorted flags                     }
  707.         scsiDriverStorage:        Ptr;                                    {  <> Ptr for driver private use         }
  708.         scsiXPTprivate:            Ptr;                                    {  private field for use in XPT             }
  709.         scsiReserved3:            LONGINT;                                {  reserved                                 }
  710.         scsiLoadedRefNum:        INTEGER;                                {  <- SIM returns refnum of driver          }
  711.         scsiDiskLoadFailed:        BOOLEAN;                                {  -> if true, indicates call after failure to load  }
  712.         filler:                    SInt8;
  713.     END;
  714.  
  715. {$ENDC}
  716. {$IFC FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE }
  717. {  Defines for the scsiTransferType field  }
  718.  
  719. CONST
  720.     scsiTransferBlind            = 0;
  721.     scsiTransferPolled            = 1;
  722.  
  723.     scsiErrorBase                = -7936;
  724.  
  725.     scsiRequestInProgress        = 1;                            {  1     = PB request is in progress              }
  726.                                                                 {  Execution failed  00-2F  }
  727.     scsiRequestAborted            = -7934;                        {  -7934 = PB request aborted by the host          }
  728.     scsiUnableToAbort            = -7933;                        {  -7933 = Unable to Abort PB request              }
  729.     scsiNonZeroStatus            = -7932;                        {  -7932 = PB request completed with an err      }
  730.     scsiUnused05                = -7931;                        {  -7931 =                                       }
  731.     scsiUnused06                = -7930;                        {  -7930 =                                       }
  732.     scsiUnused07                = -7929;                        {  -7929 =                                       }
  733.     scsiUnused08                = -7928;                        {  -7928 =                                       }
  734.     scsiUnableToTerminate        = -7927;                        {  -7927 = Unable to Terminate I/O PB req          }
  735.     scsiSelectTimeout            = -7926;                        {  -7926 = Target selection timeout              }
  736.     scsiCommandTimeout            = -7925;                        {  -7925 = Command timeout                       }
  737.     scsiIdentifyMessageRejected    = -7924;                        {  -7924 =                                       }
  738.     scsiMessageRejectReceived    = -7923;                        {  -7923 = Message reject received                  }
  739.     scsiSCSIBusReset            = -7922;                        {  -7922 = SCSI bus reset sent/received          }
  740.     scsiParityError                = -7921;                        {  -7921 = Uncorrectable parity error occured      }
  741.     scsiAutosenseFailed            = -7920;                        {  -7920 = Autosense: Request sense cmd fail      }
  742.     scsiUnused11                = -7919;                        {  -7919 =                                       }
  743.     scsiDataRunError            = -7918;                        {  -7918 = Data overrun/underrun error           }
  744.     scsiUnexpectedBusFree        = -7917;                        {  -7917 = Unexpected BUS free                      }
  745.     scsiSequenceFailed            = -7916;                        {  -7916 = Target bus phase sequence failure      }
  746.     scsiWrongDirection            = -7915;                        {  -7915 = Data phase was in wrong direction      }
  747.     scsiUnused16                = -7914;                        {  -7914 =                                       }
  748.     scsiBDRsent                    = -7913;                        {  -7913 = A SCSI BDR msg was sent to target      }
  749.     scsiTerminated                = -7912;                        {  -7912 = PB request terminated by the host      }
  750.     scsiNoNexus                    = -7911;                        {  -7911 = Nexus is not established              }
  751.     scsiCDBReceived                = -7910;                        {  -7910 = The SCSI CDB has been received          }
  752.                                                                 {  Couldn't begin execution  30-3F  }
  753.     scsiTooManyBuses            = -7888;                        {  -7888 = Register failed because we're full     }
  754.     scsiBusy                    = -7887;                        {  -7887 = SCSI subsystem is busy                  }
  755.     scsiProvideFail                = -7886;                        {  -7886 = Unable to provide requ. capability     }
  756.     scsiDeviceNotThere            = -7885;                        {  -7885 = SCSI device not installed/there       }
  757.     scsiNoHBA                    = -7884;                        {  -7884 = No HBA detected Error                  }
  758.     scsiDeviceConflict            = -7883;                        {  -7883 = sorry, max 1 refNum per DeviceIdent      }
  759.     scsiNoSuchXref                = -7882;                        {  -7882 = no such RefNum xref                      }
  760.     scsiQLinkInvalid            = -7881;                        {  -7881 = pre-linked PBs not supported             }
  761.                                                                 {    (The QLink field was nonzero)                 }
  762.                                                                 {  Parameter errors  40-7F  }
  763.     scsiPBLengthError            = -7872;                        {  -7872 = (scsiPBLength is insuf'ct/invalid      }
  764.     scsiFunctionNotAvailable    = -7871;                        {  -7871 = The requ. func is not available       }
  765.     scsiRequestInvalid            = -7870;                        {  -7870 = PB request is invalid                  }
  766.     scsiBusInvalid                = -7869;                        {  -7869 = Bus ID supplied is invalid               }
  767.     scsiTIDInvalid                = -7868;                        {  -7868 = Target ID supplied is invalid          }
  768.     scsiLUNInvalid                = -7867;                        {  -7867 = LUN supplied is invalid               }
  769.     scsiIDInvalid                = -7866;                        {  -7866 = The initiator ID is invalid           }
  770.     scsiDataTypeInvalid            = -7865;                        {  -7865 = scsiDataType requested not supported  }
  771.     scsiTransferTypeInvalid        = -7864;                        {  -7864 = scsiTransferType field is too high      }
  772.     scsiCDBLengthInvalid        = -7863;                        {  -7863 = scsiCDBLength field is too big          }
  773.  
  774. {  New errors for SCSI Family          }
  775.     kSCSITargetProbeInvalidState = -7862;                        {  -7862 = bus prober internal software error      }
  776.     scsiBadObjectID                = -7861;                        {  -7861 = bad object ID to send message         }
  777.     scsiBadDataLength            = -7860;                        {  -7860 = a zero data length in PB              }
  778.     scsiPartialPrepared            = -7859;                        {  -7859 = could not do full prepare mem for I/O }
  779.     scsiBadPBSize                = -7872;                        {  -7872 = Incorrect parameter block size        }
  780.     scsiInvalidMsgType            = -7858;                        {  -7858 = Invalid message type           }
  781.     scsiInvalidRegID            = -7857;                        {  -7857 = Invalid registry Entry ID       }
  782.     scsiBadConnID                = -7856;                        {  -7856 = Bad Connection ID               }
  783.     scsiBadIOTag                = -7855;                        {  -7855 = Bad IO Tag                     }
  784.     scsiIOInProgress            = -7854;                        {  -7854 = Can't close conn, IO in prog     }
  785.     scsiTargetReserved            = -7853;                        {  -7853 = Target already reserved         }
  786.     scsiTargetInUsed            = -7852;                        {  -7852 = Target is in used can't resv     }
  787.     scsiNoReserveOnBus            = -7851;                        {  -7851 = Can't reserved on bus         }
  788.     scsiBadConnType                = -7850;                        {  -7850 = Bad connection type             }
  789.  
  790.     scsiExecutionErrors            = -7936;
  791.     scsiNotExecutedErrors        = -7888;
  792.     scsiParameterErrors            = -7872;
  793.  
  794. {  Defines for the scsiResultFlags field  }
  795.     scsiSIMQFrozen                = $0001;                        {  The SIM queue is frozen w/this err             }
  796.     scsiAutosenseValid            = $0002;                        {  Autosense data valid for target               }
  797.     scsiBusNotFree                = $0004;                        {  At time of callback, SCSI bus is not free     }
  798.  
  799. {  Defines for the bit numbers of the scsiFlags field in the PB header for the SCSIExecIO function  }
  800.     kbSCSIDisableAutosense        = 29;                            {  Disable auto sense feature                      }
  801.     kbSCSIFlagReservedA            = 28;                            {                                                }
  802.     kbSCSIFlagReserved0            = 27;                            {                                                }
  803.     kbSCSICDBLinked                = 26;                            {  The PB contains a linked CDB                     }
  804.     kbSCSIQEnable                = 25;                            {  Target queue actions are enabled                 }
  805.     kbSCSICDBIsPointer            = 24;                            {  The CDB field contains a pointer                 }
  806.     kbSCSIFlagReserved1            = 23;                            {                                                   }
  807.     kbSCSIInitiateSyncData        = 22;                            {  Attempt Sync data xfer and SDTR                 }
  808.     kbSCSIDisableSyncData        = 21;                            {  Disable sync, go to async                     }
  809.     kbSCSISIMQHead                = 20;                            {  Place PB at the head of SIM Q                 }
  810.     kbSCSISIMQFreeze            = 19;                            {  Return the SIM Q to frozen state                 }
  811.     kbSCSISIMQNoFreeze            = 18;                            {  Disallow SIM Q freezing                         }
  812.     kbSCSIDoDisconnect            = 17;                            {  Definitely do disconnect                         }
  813.     kbSCSIDontDisconnect        = 16;                            {  Definitely don't disconnect                     }
  814.     kbSCSIDataReadyForDMA        = 15;                            {  Data buffer(s) are ready for DMA                 }
  815.     kbSCSIFlagReserved3            = 14;                            {                                                   }
  816.     kbSCSIDataPhysical            = 13;                            {  SG/Buffer data ptrs are physical                 }
  817.     kbSCSISensePhysical            = 12;                            {  Autosense buffer ptr is physical                 }
  818.     kbSCSIFlagReserved5            = 11;                            {                                                   }
  819.     kbSCSIFlagReserved6            = 10;                            {                                                   }
  820.     kbSCSIFlagReserved7            = 9;                            {                                                   }
  821.     kbSCSIFlagReserved8            = 8;                            {                                                   }
  822.     kbSCSIDataBufferValid        = 7;                            {  Data buffer valid                             }
  823.     kbSCSIStatusBufferValid        = 6;                            {  Status buffer valid                              }
  824.     kbSCSIMessageBufferValid    = 5;                            {  Message buffer valid                             }
  825.     kbSCSIFlagReserved9            = 4;                            {                                                }
  826.  
  827. {  Defines for the bit masks of the scsiFlags field  }
  828.     scsiDirectionMask            = $C0000000;                    {  Data direction mask                         }
  829.     scsiDirectionNone            = $C0000000;                    {  Data direction (11: no data)                 }
  830.     scsiDirectionReserved        = $00000000;                    {  Data direction (00: reserved)             }
  831.     scsiDirectionOut            = $80000000;                    {  Data direction (10: DATA OUT)             }
  832.     scsiDirectionIn                = $40000000;                    {  Data direction (01: DATA IN)                 }
  833.     scsiDisableAutosense        = $20000000;                    {  Disable auto sense feature                 }
  834.     scsiFlagReservedA            = $10000000;                    {                                               }
  835.     scsiFlagReserved0            = $08000000;                    {                                               }
  836.     scsiCDBLinked                = $04000000;                    {  The PB contains a linked CDB                 }
  837.     scsiQEnable                    = $02000000;                    {  Target queue actions are enabled             }
  838.     scsiCDBIsPointer            = $01000000;                    {  The CDB field contains a pointer             }
  839.     scsiFlagReserved1            = $00800000;                    {                                               }
  840.     scsiInitiateSyncData        = $00400000;                    {  Attempt Sync data xfer and SDTR             }
  841.     scsiDisableSyncData            = $00200000;                    {  Disable sync, go to async                 }
  842.     scsiSIMQHead                = $00100000;                    {  Place PB at the head of SIM Q             }
  843.     scsiSIMQFreeze                = $00080000;                    {  Return the SIM Q to frozen state             }
  844.     scsiSIMQNoFreeze            = $00040000;                    {  Disallow SIM Q freezing                     }
  845.     scsiDoDisconnect            = $00020000;                    {  Definitely do disconnect                     }
  846.     scsiDontDisconnect            = $00010000;                    {  Definitely don't disconnect                 }
  847.     scsiDataReadyForDMA            = $00008000;                    {  Data buffer(s) are ready for DMA             }
  848.     scsiFlagReserved3            = $00004000;                    {    }
  849.     scsiDataPhysical            = $00002000;                    {  SG/Buffer data ptrs are physical             }
  850.     scsiSensePhysical            = $00001000;                    {  Autosense buffer ptr is physical             }
  851.     scsiFlagReserved5            = $00000800;                    {                                            }
  852.     scsiFlagReserved6            = $00000400;                    {                                               }
  853.     scsiFlagReserved7            = $00000200;                    {                                               }
  854.     scsiFlagReserved8            = $00000100;                    {                                               }
  855.  
  856. {  bit masks for the scsiIOFlags field in SCSIExecIOPB  }
  857.     scsiNoParityCheck            = $0002;                        {  disable parity checking                              }
  858.     scsiDisableSelectWAtn        = $0004;                        {  disable select w/Atn                               }
  859.     scsiSavePtrOnDisconnect        = $0008;                        {  do SaveDataPointer upon Disconnect msg              }
  860.     scsiNoBucketIn                = $0010;                        {  don't bit bucket in during this I/O                  }
  861.     scsiNoBucketOut                = $0020;                        {  don't bit bucket out during this I/O              }
  862.     scsiDisableWide                = $0040;                        {  disable wide transfer negotiation                  }
  863.     scsiInitiateWide            = $0080;                        {  initiate wide transfer negotiation                  }
  864.     scsiRenegotiateSense        = $0100;                        {  renegotiate sync/wide before issuing autosense      }
  865.     scsiDisableDiscipline        = $0200;                        {  disable parameter checking on SCSIExecIO calls     }
  866.     scsiIOFlagReserved0080        = $0080;                        {                                                    }
  867.     scsiIOFlagReserved8000        = $8000;                        {                                                       }
  868.  
  869. {  Defines for the Bus Inquiry PB fields.  }
  870. {  scsiHBAInquiry field bits  }
  871.     scsiBusMDP                    = $80;                            {  Supports Modify Data Pointer message                         }
  872.     scsiBusWide32                = $40;                            {  Supports 32 bit wide SCSI                                 }
  873.     scsiBusWide16                = $20;                            {  Supports 16 bit wide SCSI                                 }
  874.     scsiBusSDTR                    = $10;                            {  Supports Sync Data Transfer Req message                     }
  875.     scsiBusLinkedCDB            = $08;                            {  Supports linked CDBs                                         }
  876.     scsiBusTagQ                    = $02;                            {  Supports tag queue message                                 }
  877.     scsiBusSoftReset            = $01;                            {  Supports soft reset                                         }
  878.  
  879. {  Defines for the scsiDataType field  }
  880.     scsiDataBuffer                = 0;                            {  single contiguous buffer supplied                   }
  881.     scsiDataTIB                    = 1;                            {  TIB supplied (ptr in scsiDataPtr)                  }
  882.     scsiDataSG                    = 2;                            {  scatter/gather list supplied                       }
  883.     scsiDataIOTable                = 3;                            { #(7/11/95) Prepared by Block Storage               }
  884.     scsiDataMemList                = 4;                            {  (2/6/96) Memory list }
  885.  
  886. {  scsiDataTypes field bits   }
  887. {     bits 0->15 Apple-defined, 16->30 3rd-party unique, 31 = reserved  }
  888.     scsiBusDataTIB                = $02;                            {  TIB supplied (ptr in scsiDataPtr)         }
  889.     scsiBusDataBuffer            = $01;                            {  single contiguous buffer supplied          }
  890.     scsiBusDataSG                = $04;                            {  scatter/gather list supplied              }
  891.     scsiBusDataIOTable            = $08;                            {  (2/6/95) Prepare Memory for IO }
  892.     scsiBusDataMemList            = $10;                            {  (2/6/96) Memory list }
  893.     scsiBusDataReserved            = $80000000;                    {                                             }
  894.  
  895. {  scsiScanFlags field bits  }
  896.     scsiBusScansDevices            = $80;                            {  Bus scans for and maintains device list             }
  897.     scsiBusScansOnInit            = $40;                            {  Bus scans performed at power-up/reboot             }
  898.     scsiBusLoadsROMDrivers        = $20;                            {  may load ROM drivers to support targets              }
  899.  
  900. {  scsiFeatureFlags field bits  }
  901.     scsiBusInternalExternalMask    = $000000C0;                    {  bus internal/external mask                     }
  902.     scsiBusInternalExternalUnknown = $00000000;                    {  not known whether bus is inside or outside      }
  903.     scsiBusInternalExternal        = $000000C0;                    {  bus goes inside and outside the box              }
  904.     scsiBusInternal                = $00000080;                    {  bus goes inside the box                          }
  905.     scsiBusExternal                = $00000040;                    {  bus goes outside the box                      }
  906.     scsiBusCacheCoherentDMA        = $00000020;                    {  DMA is cache coherent                          }
  907.     scsiBusOldCallCapable        = $00000010;                    {  SIM is old call capable                          }
  908.     scsiBusDifferential            = $00000004;                    {  Single Ended (0) or Differential (1)          }
  909.     scsiBusFastSCSI                = $00000002;                    {  HBA supports fast SCSI                          }
  910.     scsiBusDMAavailable            = $00000001;                    {  DMA is available                              }
  911.  
  912. {  scsiWeirdStuff field bits  }
  913.     scsiOddDisconnectUnsafeRead1 = $0001;                        {  Disconnects on odd byte boundries are unsafe with DMA and/or blind reads  }
  914.     scsiOddDisconnectUnsafeWrite1 = $0002;                        {  Disconnects on odd byte boundries are unsafe with DMA and/or blind writes  }
  915.     scsiBusErrorsUnsafe            = $0004;                        {  Non-handshaked delays or disconnects during blind transfers may cause a crash  }
  916.     scsiRequiresHandshake        = $0008;                        {  Non-handshaked delays or disconnects during blind transfers may cause data corruption  }
  917.     scsiTargetDrivenSDTRSafe    = $0010;                        {  Targets which initiate synchronous negotiations are supported  }
  918.     scsiOddCountForPhysicalUnsafe = $0020;                        {  If using physical addrs all counts must be even, and disconnects must be on even boundries  }
  919.     scsiAbortCmdFixed            = $0040;                        {  Set if abort command is fixed to properly make callbacks  }
  920.  
  921. {  scsiHBAslotType values  }
  922.     scsiMotherboardBus            = $01;                            {  A built in Apple supplied bus                      }
  923.     scsiNuBus                    = $02;                            {  A SIM on a NuBus card                              }
  924.     scsiPDSBus                    = $03;                            {     "  on a PDS card                                 }
  925.     scsiPCIBus                    = $04;                            {     "  on a PCI bus card                             }
  926.     scsiPCMCIABus                = $05;                            {     "  on a PCMCIA card                             }
  927.     scsiFireWireBridgeBus        = $06;                            {     "  connected through a FireWire bridge         }
  928.  
  929. {$ENDC}
  930. {$IFC FOR_SYSTEM7_ONLY }
  931. {  Defines for the scsiDriverFlags field (in SCSIDriverPB)  }
  932.  
  933. CONST
  934.     scsiDeviceSensitive            = $0001;                        {  Only driver should access this device                 }
  935.     scsiDeviceNoOldCallAccess    = $0002;                        {  no old call access to this device                      }
  936.  
  937. {  SCSI status }
  938.     scsiStatGood                = $00;                            {  Good Status }
  939.     scsiStatCheckCondition        = $02;                            {  Check Condition }
  940.     scsiStatConditionMet        = $04;                            {  Condition Met }
  941.     scsiStatBusy                = $08;                            {  Busy }
  942.     scsiStatIntermediate        = $10;                            {  Intermediate }
  943.     scsiStatIntermedMet            = $14;                            {  Intermediate - Condition Met }
  944.     scsiStatResvConflict        = $18;                            {  Reservation conflict }
  945.     scsiStatTerminated            = $20;                            {  Command terminated }
  946.     scsiStatQFull                = $28;                            {  Queue full }
  947.  
  948. {  SCSI messages }
  949.     kCmdCompleteMsg                = 0;
  950.     kExtendedMsg                = 1;                            {  0x01 }
  951.     kSaveDataPointerMsg            = 2;                            {  0x02 }
  952.     kRestorePointersMsg            = 3;                            {  0x03 }
  953.     kDisconnectMsg                = 4;                            {  0x04 }
  954.     kInitiatorDetectedErrorMsg    = 5;                            {  0x05 }
  955.     kAbortMsg                    = 6;                            {  0x06 }
  956.     kMsgRejectMsg                = 7;                            {  0x07 }
  957.     kNoOperationMsg                = 8;                            {  0x08 }
  958.     kMsgParityErrorMsg            = 9;                            {  0x09 }
  959.     kLinkedCmdCompleteMsg        = 10;                            {  0x0a }
  960.     kLinkedCmdCompleteWithFlagMsg = 11;                            {  0x0b }
  961.     kBusDeviceResetMsg            = 12;                            {  0x0c }
  962.     kAbortTagMsg                = 13;                            {  0x0d }
  963.     kClearQueueMsg                = 14;                            {  0x0e }
  964.     kInitiateRecoveryMsg        = 15;                            {  0x0f }
  965.     kReleaseRecoveryMsg            = 16;                            {  0x10 }
  966.     kTerminateIOProcessMsg        = 17;                            {  0x11 }
  967.     kSimpleQueueTag                = $20;                            {  0x20 }
  968.     kHeadOfQueueTagMsg            = $21;                            {  0x21 }
  969.     kOrderedQueueTagMsg            = $22;                            {  0x22 }
  970.     kIgnoreWideResidueMsg        = $23;                            {  0x23 }
  971.  
  972. {$ENDC}
  973. {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE }
  974. {   SIMInitInfo PB  }
  975. {  directions are for SCSIRegisterBus call ( -> parm, <- result)              }
  976.  
  977. TYPE
  978.     SIMInitInfoPtr = ^SIMInitInfo;
  979.     SIMInitInfo = RECORD
  980.         SIMstaticPtr:            Ptr;                                    {  <- alloc. ptr to the SIM's static vars                  }
  981.         staticSize:                LONGINT;                                {  -> num bytes SIM needs for static vars                  }
  982.         SIMInit:                SIMInitUPP;                                {  -> pointer to the SIM init routine                      }
  983.         SIMAction:                SIMActionUPP;                            {  -> pointer to the SIM action routine                  }
  984.         SIM_ISR:                SCSIInterruptUPP;                        {        reserved                                              }
  985.         SIMInterruptPoll:        SCSIInterruptUPP;                        {  -> pointer to the SIM interrupt poll routine             }
  986.         NewOldCall:                SIMActionUPP;                            {  -> pointer to the SIM NewOldCall routine                 }
  987.         ioPBSize:                UInt16;                                    {  -> size of SCSI_IO_PBs required for this SIM             }
  988.         oldCallCapable:            BOOLEAN;                                {  -> true if this SIM can handle old-API calls             }
  989.         simInfoUnused1:            SInt8;                                    {        reserved                                             }
  990.         simInternalUse:            LONGINT;                                {  xx not affected or viewed by XPT                         }
  991.         XPT_ISR:                SCSIUPP;                                {     reserved                                             }
  992.         EnteringSIM:            SCSIUPP;                                {  <- ptr to the EnteringSIM routine                     }
  993.         ExitingSIM:                SCSIUPP;                                {  <- ptr to the ExitingSIM routine                         }
  994.         MakeCallback:            SCSIMakeCallbackUPP;                    {  <- the XPT layer's SCSIMakeCallback routine             }
  995.         busID:                    UInt16;                                    {  <- bus number for the registered bus                     }
  996.         simSlotNumber:            SInt8;                                    {  <- Magic cookie to place in scsiHBASlotNumber (PCI)     }
  997.         simSRsrcID:                SInt8;                                    {  <- Magic cookie to place in scsiSIMsRsrcID     (PCI)     }
  998.         simRegEntry:            Ptr;                                    {  -> The SIM's RegEntryIDPtr                     (PCI)     }
  999.     END;
  1000.  
  1001. {  Glue between SCSI calls and SCSITrap format  }
  1002.  
  1003. CONST
  1004.     xptSCSIAction                = $0001;
  1005.     xptSCSIRegisterBus            = $0002;
  1006.     xptSCSIDeregisterBus        = $0003;
  1007.     xptSCSIReregisterBus        = $0004;
  1008.     xptSCSIKillXPT                = $0005;                        {  kills Mini-XPT after transition  }
  1009.     xptSCSIInitialize            = $000A;                        {  Initialize the SCSI manager  }
  1010.  
  1011. {  moveq #kSCSIx, D0;  _SCSIAtomic  }
  1012. FUNCTION SCSIAction(VAR parameterBlock: SCSI_PB): OSErr;
  1013.     {$IFC NOT GENERATINGCFM}
  1014.     INLINE $205F, $7001, $A089, $3E80;
  1015.     {$ENDC}
  1016. FUNCTION SCSIRegisterBus(VAR parameterBlock: SIMInitInfo): OSErr;
  1017.     {$IFC NOT GENERATINGCFM}
  1018.     INLINE $205F, $7002, $A089, $3E80;
  1019.     {$ENDC}
  1020. FUNCTION SCSIDeregisterBus(VAR parameterBlock: SCSI_PB): OSErr;
  1021.     {$IFC NOT GENERATINGCFM}
  1022.     INLINE $205F, $7003, $A089, $3E80;
  1023.     {$ENDC}
  1024. FUNCTION SCSIReregisterBus(VAR parameterBlock: SIMInitInfo): OSErr;
  1025.     {$IFC NOT GENERATINGCFM}
  1026.     INLINE $205F, $7004, $A089, $3E80;
  1027.     {$ENDC}
  1028. FUNCTION SCSIKillXPT(VAR parameterBlock: SIMInitInfo): OSErr;
  1029.     {$IFC NOT GENERATINGCFM}
  1030.     INLINE $205F, $7005, $A089, $3E80;
  1031.     {$ENDC}
  1032. FUNCTION SCSIInitBFPI: OSStatus; C;
  1033. {$ENDC}
  1034. {$IFC FOR_SYSTEM8_PREEMPTIVE }
  1035. {
  1036.     File:        SCSIConn.h
  1037.  
  1038.     Contains:    Connection Based parameter checking
  1039.  
  1040.     Version:    0.1
  1041.  
  1042.     Written by:    Darryl Chan
  1043.  
  1044.     Copyright:    © 1995-1996 by Apple Computer, Inc., all rights reserved.
  1045.  
  1046.     File Ownership:
  1047.  
  1048.         DRI:                Darryl Chan
  1049.  
  1050.         Other Contact:        Stanford Au
  1051.  
  1052.         Technology:            IO Group
  1053.  
  1054.     Writers:
  1055.  
  1056.         (DC)    Darryl Chan
  1057.  
  1058.     Change History (most recent first):
  1059.  
  1060.          <4>     1/25/96    DC        Integrate to D11 - name registry changes
  1061.          <3>     1/18/96    DC        Split file to public and private interfaces and converting to
  1062.                                     MrC.
  1063.          <2>     1/15/96    DC        Add more commands
  1064.          <1>      1/3/96    DC        First checked in.
  1065.  
  1066. }
  1067.  
  1068. TYPE
  1069.     ConnectionType                        = UInt32;
  1070.     ConnectionID                        = ObjectID;
  1071.     SCSIExecIOTag                        = MessageID;
  1072.  
  1073. CONST
  1074.     kMaxAutoSenseByteCount        = 255;                            {  max sense byte buffer size }
  1075.  
  1076. {         values for 'type's of connection (UInt16) }
  1077.     kReservedAccess                = $0100;                        {  Reserved Access  }
  1078.     kSharedAccess                = $0200;                        {  Shared Access }
  1079.  
  1080.  
  1081. TYPE
  1082.     SCSIDataObjectPtr = ^SCSIDataObject;
  1083.     SCSIDataObject = RECORD
  1084.         scsiDataPtr:            Ptr;
  1085.         scsiDataLength:            SInt32;
  1086.         scsiDataType:            UInt16;
  1087.         scsiSGListCount:        UInt16;
  1088.     END;
  1089.  
  1090.     SCSICDBObjectPtr = ^SCSICDBObject;
  1091.     SCSICDBObject = RECORD
  1092.         scsiCDBLength:            UInt16;
  1093.         scsiCDB:                CDB;
  1094.     END;
  1095.  
  1096.     SCSIFlagsObjectPtr = ^SCSIFlagsObject;
  1097.     SCSIFlagsObject = RECORD
  1098.         scsiFlags:                UInt32;
  1099.         scsiIOFlags:            UInt16;
  1100.         scsiTransferType:        UInt16;
  1101.     END;
  1102.  
  1103.     SCSIExecIOResultPtr = ^SCSIExecIOResult;
  1104.     SCSIExecIOResult = RECORD
  1105.         scsiResult:                OSStatus;
  1106.         scsiResultFlags:        UInt16;
  1107.         scsiSenseLength:        UInt16;                                    {  the actual sense length returned }
  1108.         scsiDataResidual:        SInt32;                                    {  residual data length }
  1109.         ioTag:                    SCSIExecIOTag;
  1110.         scsiSense:                PACKED ARRAY [0..254] OF UInt8;            {  maximum sense buffer }
  1111.         scsiSCSIstatus:            SInt8;
  1112.     END;
  1113.  
  1114.     SCSIIOOptionsObjectPtr = ^SCSIIOOptionsObject;
  1115.     SCSIIOOptionsObject = RECORD
  1116.         scsiFlags:                UInt32;
  1117.         scsiIOFlags:            UInt32;
  1118.     END;
  1119.  
  1120.     SCSIHandshakeObjectPtr = ^SCSIHandshakeObject;
  1121.     SCSIHandshakeObject = RECORD
  1122.         scsiHandshake:            ARRAY [0..7] OF UInt16;
  1123.     END;
  1124.  
  1125.     SCSIBusInfoPtr = ^SCSIBusInfo;
  1126.     SCSIBusInfo = RECORD
  1127.         scsiEngineCount:        UInt16;                                    {  <- Number of engines on HBA                          }
  1128.         scsiMaxTransferType:    UInt16;                                    {  <- Number of transfer types for this HBA             }
  1129.         scsiDataTypes:            UInt32;                                    {  <- which data types are supported by this SIM      }
  1130.         scsiBIReserved4:        UInt32;                                    {  <-                                                   }
  1131.         scsiFeatureFlags:        UInt32;                                    {  <- Supported features flags field                  }
  1132.         scsiVersionNumber:        SInt8;                                    {  <- Version number for the SIM/HBA                  }
  1133.         scsiHBAInquiry:            SInt8;                                    {  <- Mimic of INQ byte 7 for the HBA                  }
  1134.         scsiTargetModeFlags:    SInt8;                                    {  <- Flags for target mode support                  }
  1135.         scsiScanFlags:            SInt8;                                    {  <- Scan related feature flags                      }
  1136.         scsiSIMPrivatesPtr:        UInt32;                                    {  <- Ptr to SIM private data area                      }
  1137.         scsiSIMPrivatesSize:    UInt32;                                    {  <- Size of SIM private data area                  }
  1138.         scsiAsyncFlags:            UInt32;                                    {  <- Event cap. for Async Callback                  }
  1139.         scsiHiBusID:            SInt8;                                    {  <- Highest path ID in the subsystem               }
  1140.         scsiInitiatorID:        SInt8;                                    {  <- ID of the HBA on the SCSI bus                  }
  1141.         scsiBIReserved0:        UInt16;                                    {                                                      }
  1142.         scsiBIReserved1:        UInt32;                                    {  <-                                                   }
  1143.         scsiFlagsSupported:        UInt32;                                    {  <- which scsiFlags are supported                  }
  1144.         scsiIOFlagsSupported:    UInt16;                                    {  <- which scsiIOFlags are supported                  }
  1145.         scsiWeirdStuff:            UInt16;                                    {  <-                                                  }
  1146.         scsiMaxTarget:            UInt16;                                    {  <- maximum Target number supported                  }
  1147.         scsiMaxLUN:                UInt16;                                    {  <- maximum Logical Unit number supported          }
  1148.         scsiSIMVendor:            PACKED ARRAY [0..15] OF CHAR;            {  <- Vendor ID of SIM (or XPT if bus<FF)          }
  1149.         scsiHBAVendor:            PACKED ARRAY [0..15] OF CHAR;            {  <- Vendor ID of the HBA                          }
  1150.         scsiControllerFamily:    PACKED ARRAY [0..15] OF CHAR;            {  <- Family of SCSI Controller                  }
  1151.         scsiControllerType:        PACKED ARRAY [0..15] OF CHAR;            {  <- Specific Model of SCSI Controller used      }
  1152.         scsiXPTversion:            PACKED ARRAY [0..3] OF CHAR;            {  <- version number of XPT                          }
  1153.         scsiSIMversion:            PACKED ARRAY [0..3] OF CHAR;            {  <- version number of SIM                          }
  1154.         scsiHBAversion:            PACKED ARRAY [0..3] OF CHAR;            {  <- version number of HBA                          }
  1155.         scsiHBAslotType:        SInt8;                                    {  <- type of "slot" that this HBA is in             }
  1156.         scsiHBAslotNumber:        SInt8;                                    {  <- slot number of this HBA                          }
  1157.         scsiSIMsRsrcID:            UInt16;                                    {  <- resource ID of this SIM                          }
  1158.         scsiBIReserved3:        UInt16;                                    {  <-                                                  }
  1159.                                                                         {     UInt16        scsiAdditionalLength;    /* <- additional BusInquiry PB len                    */ }
  1160.     END;
  1161.  
  1162.  
  1163. CONST
  1164.     kSCSIDeviceTypeSize            = 9;                            {  number of characters for device type }
  1165.     kSCSIAllBus                    = $FF;                            {  search all bus }
  1166.  
  1167.  
  1168. TYPE
  1169.     DeviceType                            = PACKED ARRAY [0..8] OF CHAR;
  1170. {  this replaces SCSIDevList }
  1171.     SCSIIOIteratorDataPtr = ^SCSIIOIteratorData;
  1172.     SCSIIOIteratorData = RECORD
  1173.         deviceInfo:                IOCommonInfo;
  1174.         deviceID:                DeviceIdent;
  1175.         deviceType:                DeviceType;
  1176.     END;
  1177.  
  1178.  
  1179. CONST
  1180.     scsiVERSION                    = 80;
  1181.  
  1182. {
  1183. _____________________________________________________________________
  1184.         Client type used to identify the type of client we are dealing 
  1185.         with.
  1186. _____________________________________________________________________
  1187. }
  1188.  
  1189. TYPE
  1190.     ClientType                            = UInt8;
  1191. {      for Client type }
  1192.  
  1193. CONST
  1194.     kUserClient                    = $02;
  1195.     kPriviClient                = $01;
  1196.     kBlueUserClient                = $06;
  1197.  
  1198. {
  1199.     
  1200.     New command to get Registry Entry ID for the SCSI Plugin
  1201. }
  1202.     SCSIGetRegEntryID            = $89;                            {  Return a copy of the System Registry     }
  1203.  
  1204.  
  1205. TYPE
  1206.     SCSIGetRegEntryIDPBPtr = ^SCSIGetRegEntryIDPB;
  1207.     SCSIGetRegEntryIDPB = RECORD
  1208.         qLink:                    SCSIHdrPtr;                                {  (internal use, must be nil on entry)     }
  1209.         scsiReserved1:            INTEGER;
  1210.         scsiPBLength:            UInt16;
  1211.         scsiFunctionCode:        SInt8;
  1212.         scsiReserved2:            SInt8;
  1213.         scsiResult:                OSErr;
  1214.         scsiDevice:                DeviceIdent;
  1215.         scsiCompletion:            Ptr;
  1216.         scsiFlags:                UInt32;
  1217.         scsiDriverStorage:        BytePtr;
  1218.         scsiXPTprivate:            Ptr;
  1219.         scsiReserved3:            LONGINT;
  1220.         scsiRegEntryID:            RegEntryRef;                            {  A copy of the System Registry ID     }
  1221.     END;
  1222.  
  1223. {   Functions declarations }
  1224. FUNCTION SCSIOpenConnection(VAR regID: RegEntryRef; connType: ConnectionType; VAR connID: ConnectionID): OSStatus; C;
  1225. FUNCTION SCSICloseConnection(connID: ConnectionID): OSStatus; C;
  1226. FUNCTION SCSIExecIOSyncCmd(connID: ConnectionID; dataObject: SCSIDataObject; cdbObject: SCSICDBObject; flagsObject: SCSIFlagsObject; VAR resultBuffer: SCSIExecIOResult; VAR ioTag: SCSIExecIOTag): OSStatus; C;
  1227. FUNCTION SCSIExecIOAsyncCmd(connID: ConnectionID; VAR kernelNot: KernelNotification; dataObject: SCSIDataObject; cdbObject: SCSICDBObject; flagsObject: SCSIFlagsObject; VAR resultBuffer: SCSIExecIOResult; VAR ioTag: SCSIExecIOTag): OSStatus; C;
  1228. FUNCTION SCSIAbortIOCmd(connID: ConnectionID; ioTag: SCSIExecIOTag): OSStatus; C;
  1229. FUNCTION SCSITerminateIOCmd(connID: ConnectionID; ioTag: SCSIExecIOTag): OSStatus; C;
  1230. FUNCTION SCSIReleaseQCmd(connID: ConnectionID): OSStatus; C;
  1231. FUNCTION SCSIClearQueue(connID: ConnectionID): OSStatus; C;
  1232. FUNCTION SCSIBusResetSync(connID: ConnectionID; VAR resultBuffer: OSStatus): OSStatus; C;
  1233. FUNCTION SCSIBusResetAsync(connID: ConnectionID; VAR kernelNot: KernelNotification; VAR resultBuffer: OSStatus): OSStatus; C;
  1234. FUNCTION SCSIDeviceResetSync(connID: ConnectionID; VAR resultBuffer: OSStatus): OSStatus; C;
  1235. FUNCTION SCSIDeviceResetAsync(connID: ConnectionID; VAR kernelNot: KernelNotification; VAR resultBuffer: OSStatus): OSStatus; C;
  1236. FUNCTION SCSIBusGetDeviceData(VAR bus: UInt8; reqCount: UInt32; VAR actCount: UInt32; VAR list: SCSIIOIteratorData): OSStatus; C;
  1237. FUNCTION SCSIBusInquiryCmd(connID: ConnectionID; VAR resultBuffer: SCSIBusInfo): OSStatus; C;
  1238. FUNCTION SCSISetHandshake(connID: ConnectionID; handshake: SCSIHandshakeObject): OSStatus; C;
  1239. FUNCTION SCSISetTimeout(connID: ConnectionID; scsiTimeout: Duration; scsiSelectTimeout: UInt16): OSStatus; C;
  1240. FUNCTION SCSISetIOOptions(connID: ConnectionID; ioOptions: SCSIIOOptionsObject): OSStatus; C;
  1241. FUNCTION SCSIInitFPI: OSStatus; C;
  1242. FUNCTION SCSIServer(VAR scsiPB: SCSI_PB; VAR kernelNot: KernelNotification): OSStatus; C;
  1243. FUNCTION SCSIExecIOControlSyncCmd(connID: ConnectionID; dataObject: SCSIDataObject; deviceID: DeviceIdent; cdbObject: SCSICDBObject; flagsObject: SCSIFlagsObject; VAR resultBuffer: SCSIExecIOResult; VAR ioTag: SCSIExecIOTag): OSStatus; C;
  1244. FUNCTION SCSIExecIOControlAsyncCmd(connID: ConnectionID; VAR kernelNot: KernelNotification; dataObject: SCSIDataObject; deviceID: DeviceIdent; cdbObject: SCSICDBObject; flagsObject: SCSIFlagsObject; VAR resultBuffer: SCSIExecIOResult; VAR ioTag: SCSIExecIOTag): OSStatus; C;
  1245. {$ENDC}
  1246. {$ALIGN RESET}
  1247. {$POP}
  1248.  
  1249. {$SETC UsingIncludes := SCSIIncludes}
  1250.  
  1251. {$ENDC} {__SCSI__}
  1252.  
  1253. {$IFC NOT UsingIncludes}
  1254.  END.
  1255. {$ENDC}
  1256.